home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1256 / cob2spx.c_ / cob2spx.c
C/C++ Source or Header  |  1997-04-18  |  82KB  |  2,156 lines

  1. /* EasyCODE(C++) V5.1 02.03.1995 13:37:54 */
  2. /* EasyCODE O
  3. If=vertical
  4. LevelNumbers=no
  5. LineNumbers=no
  6. ScreenFont=Courier New,,80,9220,-11,0,400,0,0,0,0,0,0,3,2,1,49
  7. PrinterFont=Courier New,,80,17414,-34,0,400,0,0,0,0,0,0,3,2,1,49
  8. LastLevelId=445 */
  9.  
  10. /* EasyCODE ( 1
  11.    cob2spx.c */
  12.  
  13. /* EasyCODE ( 377
  14.    Includes, Constants */
  15. /* INCLUDES */
  16. #include "convio.h"
  17. #include "conv.h"
  18. #include "tabledef.h"
  19. #include <string.h>
  20. /* EasyCODE - */
  21. /* CONSTANTS */
  22. #define MAX_DELIMITERLEN  2
  23. #define MAX_ADDTEXTLEN    32
  24. #define MAX_DEPTH         64
  25. #define MAX_LEVEL         64
  26.  
  27. #define USAGEMSG    "Usage: %s inputfile outputfile [/l=<int>] [/c] [/s=<divisions>]\n"
  28. #define SPACES1     "      "
  29. #define SPACES2     "       "
  30. #define SPACES3     "        "
  31. #define L_OPT_LEN         2   /* max length of string in level option */
  32. #define S_OPT_LEN         4   /* max length of string in suppress option */
  33.  
  34. #define ERR_TEXT1   "Keyword expected                           "
  35. #define ERR_TEXT2   "Unexpected EOF                             "
  36. #define ERR_TEXT3   "Keyword is not a valid COBOL keyword       "
  37. #define ERR_TEXT4   "Maximum depth of nested constructs reached "
  38. /* EasyCODE ) */
  39.  
  40. /* EasyCODE ( 126
  41.    check_parms */
  42.  
  43. /* EasyCODE F */
  44. void check_parms( int argc, char *argv[], int *ip, int *op,
  45.                   int* maxlevel, BOOL* comment, BOOL* divisions )
  46.                   
  47.                   
  48. // Parameter check.
  49. // Mandatory are Input and Output file. 3 Options are possible
  50. //                    /l=<int>    .... Segment/level depth
  51. //                                     between 0 and 99
  52. //                    /c          .... Comments only
  53. //                    /s=<...>    .... Suppress divisions
  54. //                                     Combination of i,e,d,p
  55. //                                     (case-insensitive)
  56. // Order of arguments does not matter, only input file has to be
  57. // before output file stehen. Options are case-insensitive,
  58. // '-' may be used instead of '/'.
  59.    {
  60.    int i;
  61.    int len;
  62.    int lp = -1;       /* Position of option l in parameter string */
  63.    int cp = -1;       /* Position of option c in parameter string */
  64.    int sp = -1;       /* Position of option s in parameter string */
  65.    char *eptr;        /* End pointer for strtol()                 */
  66.    if ((argc < 3)||(argc > 6)
  67.        /* Number of arguments less than 3 or greater than 6 */)
  68.       {
  69.       /* Print usage message */
  70.       fprintf (stderr, USAGEMSG, argv[0]);
  71.       exit(0);
  72.       }
  73.    for (i=1;i<argc;i++
  74.         /* process all arguments */)
  75.       {
  76.       if ((*argv[i] == '/')||(*argv[i] == '-')
  77.           /* If Option (i.e. starting with '/' or '-' */)
  78.          {
  79.          switch (tolower(*(argv[i]+1))
  80.                  /* Which option ? */)
  81.             {
  82.             case 'l'
  83.                  /* Level option */:
  84.                if (lp < 0
  85.                    /* first 'l' option */)
  86.                   {
  87.                   lp = i;
  88.                   /* Get position (=index) */
  89.                   }
  90.                else
  91.                   {
  92.                   /* Print usage message */
  93.                   fprintf (stderr, USAGEMSG, argv[0]);
  94.                   exit(0);
  95.                   }
  96.                break;
  97.             case 'c'
  98.                  /* Comment option */:
  99.                if (cp < 0
  100.                    /* First 'c' option */)
  101.                   {
  102.                   cp = i;
  103.                   /* Get position (=index) */
  104.                   }
  105.                else
  106.                   {
  107.                   /* Print usage message */
  108.                   fprintf (stderr, USAGEMSG, argv[0]);
  109.                   exit(0);
  110.                   }
  111.                break;
  112.             case 's'
  113.                  /* Suppress option */:
  114.                if (sp < 0
  115.                    /* First 's' option */)
  116.                   {
  117.                   sp = i;
  118.                   /* Get position (=index) */
  119.                   }
  120.                else
  121.                   {
  122.                   /* Print usage message */
  123.                   fprintf (stderr, USAGEMSG, argv[0]);
  124.                   exit(0);
  125.                   }
  126.                break;
  127.             default:
  128.                /* Print usage message */
  129.                fprintf (stderr, USAGEMSG, argv[0]);
  130.                exit(0);
  131.                break;
  132.             }
  133.          }
  134.       else
  135.          {
  136.          if (*ip < 0
  137.              /* Input file not given yet */)
  138.             {
  139.             *ip = i;
  140.             /* Get position (=index) */
  141.             }
  142.          else
  143.             {
  144.             if (*op < 0
  145.                 /* Output file not given yet */)
  146.                {
  147.                *op = i;
  148.                /* Get position (=index) */
  149.                }
  150.             else
  151.                {
  152.                /* Print usage message */
  153.                fprintf (stderr, USAGEMSG, argv[0]);
  154.                exit(0);
  155.                }
  156.             }
  157.          }
  158.       }
  159.    if ((*ip < 0)||(*op < 0)
  160.        /* No input file or output file given */)
  161.       {
  162.       /* Print usage message */
  163.       fprintf (stderr, USAGEMSG, argv[0]);
  164.       exit(0);
  165.       }
  166.    else
  167.       {
  168.       if (strcmp(argv[*ip],argv[*op])==0
  169.           /* Input file and Output file identical */)
  170.          {
  171.          /* Print usage message */
  172.          fprintf (stderr, USAGEMSG, argv[0]);
  173.          exit(0);
  174.          }
  175.       }
  176.    if (lp > 0
  177.        /* 'l' option given */)
  178.       {
  179.       if (*(argv[lp]+2) != '='
  180.           /* Third character not '=' */)
  181.          {
  182.          /* Print usage message */
  183.          fprintf (stderr, USAGEMSG, argv[0]);
  184.          exit(0);
  185.          }
  186.       else
  187.          {
  188.          if (strlen(argv[lp]) > L_OPT_LEN + 3
  189.              /* 'l' string too long */)
  190.             {
  191.             /* Print usage message */
  192.             fprintf (stderr, USAGEMSG, argv[0]);
  193.             exit(0);
  194.             }
  195.          else
  196.             {
  197.             /* Convert string to number */
  198.             *maxlevel = (int) strtol( (argv[lp]+3), &eptr, 10 );
  199.             if ((*eptr != '\0') || (eptr == (argv[lp]+3))
  200.                 /* String contains other characters than numbers*/)
  201.                {
  202.                /* Print usage message */
  203.                fprintf (stderr, USAGEMSG, argv[0]);
  204.                exit(0);
  205.                }
  206.             }
  207.          }
  208.       }
  209.    else
  210.       {
  211.       /* No 'l' option */
  212.       }
  213.    if (cp > 0
  214.        /* 'c' option given */)
  215.       {
  216.       if (strlen(argv[cp]) > 2
  217.           /* 'c' option too long */)
  218.          {
  219.          /* Print usage message */
  220.          fprintf (stderr, USAGEMSG, argv[0]);
  221.          exit(0);
  222.          }
  223.       else
  224.          {
  225.          /* Set comment flag */
  226.          *comment = TRUE;
  227.          }
  228.       }
  229.    else
  230.       {
  231.       /* No 'c' option */
  232.       }
  233.    if (sp > 0
  234.        /* 's' option given */)
  235.       {
  236.       if (*(argv[sp]+2) != '='
  237.           /* Third character not '=' */)
  238.          {
  239.          /* Print usage message */
  240.          fprintf (stderr, USAGEMSG, argv[0]);
  241.          exit(0);
  242.          }
  243.       else
  244.          {
  245.          if ((len = strlen(argv[sp])) > S_OPT_LEN + 3
  246.              /* 's' string to long */)
  247.             {
  248.             /* Print usage message */
  249.             fprintf (stderr, USAGEMSG, argv[0]);
  250.             exit(0);
  251.             }
  252.          else
  253.             {
  254.             for (i=0;i<len-3;i++
  255.                  /* Process characters in argument string */)
  256.                {
  257.                switch (tolower(*(argv[sp]+3+i))
  258.                        /* Process i-th character after '=' */)
  259.                   {
  260.                   case 'i'
  261.                        /* Suppress Identification Division (=i) */:
  262.                      if (*divisions
  263.                          /* divisions[0] is TRUE */)
  264.                         {
  265.                         *divisions = FALSE;
  266.                         /* divisions[0] set to FALSE */
  267.                         }
  268.                      else
  269.                         {
  270.                         /* Print usage message */
  271.                         fprintf (stderr, USAGEMSG, argv[0]);
  272.                         exit(0);
  273.                         }
  274.                      break;
  275.                   case 'e'
  276.                        /* Suppress Environment Division (=e) */:
  277.                      if (*(divisions+1)
  278.                          /* divisions[1] is TRUE */)
  279.                         {
  280.                         *(divisions+1) = FALSE;
  281.                         /* divisions[1] set to FALSE */
  282.                         }
  283.                      else
  284.                         {
  285.                         /* Print usage message */
  286.                         fprintf (stderr, USAGEMSG, argv[0]);
  287.                         exit(0);
  288.                         }
  289.                      break;
  290.                   case 'd'
  291.                        /* Suppress Data Division (=d) */:
  292.                      if (*(divisions+2)
  293.                          /* divisions[2] is TRUE */)
  294.                         {
  295.                         *(divisions+2) = FALSE;
  296.                         /* divisions[2] set to FALSE */
  297.                         }
  298.                      else
  299.                         {
  300.                         /* Print usage message */
  301.                         fprintf (stderr, USAGEMSG, argv[0]);
  302.                         exit(0);
  303.                         }
  304.                      break;
  305.                   case 'p'
  306.                        /* Suppress Procedure Division (=p) */:
  307.                      if (*(divisions+3)
  308.                          /* divisions[3] is TRUE */)
  309.                         {
  310.                         *(divisions+3) = FALSE;
  311.                         /* divisions[3] set to FALSE */
  312.                         }
  313.                      else
  314.                         {
  315.                         /* Print usage message */
  316.                         fprintf (stderr, USAGEMSG, argv[0]);
  317.                         exit(0);
  318.                         }
  319.                      break;
  320.                   default:
  321.                      /* Print usage message */
  322.                      fprintf (stderr, USAGEMSG, argv[0]);
  323.                      exit(0);
  324.                   }
  325.                }
  326.             }
  327.          }
  328.       }
  329.    else
  330.       {
  331.       /* No 's' option */
  332.       }
  333.    }
  334. /* EasyCODE ) */
  335.  
  336. /* EasyCODE ( 18
  337.    Set_addText */
  338.  
  339. /* EasyCODE F */
  340. void Set_addText(BOOL omit, char* addText, char* string)
  341.  
  342. // Sets variable addText;
  343. // addText will be placed in front of or behind
  344. // the next text line;
  345.    {
  346.    if (!omit
  347.        /* Omit indicator is FALSE */)
  348.       {
  349.       strcpy(addText,string);
  350.       /* Copy given string to addText */
  351.       }
  352.    }
  353. /* EasyCODE ) */
  354.  
  355. /* EasyCODE ( 15
  356.    StoreText */
  357.  
  358. /* EasyCODE F */
  359. void StoreText(FILE* stream, BOOL omit, BOOL comment,
  360.                char* keyword, char* delimiter,
  361.                char* addText, char* contents)
  362.                
  363.  
  364. // Writes a text line to the output file.
  365. // The text is written either unmodified, or suppressed
  366. // (comment is TRUE), modified (addText not empty);
  367. // or inserted (contents is empty);
  368.    {
  369.    int len;
  370.    int i;
  371.    int num;              /* Contains number in numstr */        
  372.    char numstr  [4];     /* Number string extracted from addText */
  373.    char *addText2;
  374.    /* EasyCODE - */
  375.    addText2    = malloc((MAX_ADDTEXTLEN+1)*sizeof(char));
  376.    /* Allocate memory */
  377.    if (!omit
  378.        /* Omit indicator is FALSE */)
  379.       {
  380.       if (comment
  381.           /* comment is TRUE */)
  382.          {
  383.          // Only comment is written, plus additional text
  384.          // created for SPX.
  385.          if ((*contents == '/')||(*contents == '*')||(*addText != '\0')
  386.              /* Text is comment or addText is not empty */)
  387.             {
  388.             if (((*contents == '/')||(*contents == '*'))&&(*addText != '\0')
  389.                 /* Text is comment and addText is not empty */)
  390.                {
  391.                // Comment + addText is written
  392.                if (*addText != '<'
  393.                    /* addText does not contain a number string starting with '<' */)
  394.                   {
  395.                   // Additional text is inserted at begin of line
  396.                   if (*contents == '\0'
  397.                       /* contents is empty */)
  398.                      {
  399.                      *contents = '\n';
  400.                      *(contents+1) = '\0';
  401.                      /* newline and end-of-string are added */
  402.                      }
  403.                   /* Buffer assembled again */
  404.                   strcpy(inbuf,keyword);
  405.                   strcat(inbuf,delimiter);
  406.                   strcat(inbuf,addText);
  407.                   strcat(inbuf,contents);
  408.                   if (strcmp(addText,"USING ")==0
  409.                       /* addText contains USING */)
  410.                      {
  411.                      strcpy(addText,SPACES1);
  412.                      /* SPACES1 copied to addText */
  413.                      /* to get indent for following lines */
  414.                      }
  415.                   if (strcmp(addText,"SEARCH ")==0
  416.                       /* addText contains SEARCH */)
  417.                      {
  418.                      strcpy(addText,SPACES2);
  419.                      /* SPACES2 copied to addText */
  420.                      /* to get indent for following lines */
  421.                      }
  422.                   if (strcmp(addText,"VARYING ")==0
  423.                       /* addText contains VARYING */)
  424.                      {
  425.                      strcpy(addText,SPACES3);
  426.                      /* SPACES3 copied to addText */
  427.                      /* to get indent for following lines */
  428.                      }
  429.                   if (!((strcmp(addText,SPACES1)==0)||
  430.                         (strcmp(addText,SPACES2)==0)||
  431.                         (strcmp(addText,SPACES3)==0))
  432.                       
  433.                       /* addText contains neither SPACES1 nor SPACES2 nor SPACES3 */)
  434.                      {
  435.                      strcpy(addText,"");
  436.                      /* Clear addText */
  437.                      }
  438.                   }
  439.                else
  440.                   {
  441.                   // addText to be written at the end of the last
  442.                   // comment line of the construct header
  443.                   /* EasyCODE - */
  444.                   // addText is written if number at begin of string
  445.                   // between < and > is 1.
  446.                   /* EasyCODE - */
  447.                   strcpy(addText2,addText);
  448.                   /* EasyCODE - */
  449.                   len = 0;
  450.                   /* Length of number string initialized with 0 */
  451.                   /* EasyCODE - */
  452.                   addText2++;
  453.                   /* Set pointer to begin of number string */
  454.                   while (*addText2++ != '>'
  455.                          /* Number string not finished */)
  456.                      {
  457.                      len++;
  458.                      /* Increment length */
  459.                      }
  460.                   for (i=1;i<=len;i++
  461.                        /* While index less than length */)
  462.                      {
  463.                      numstr[i-1] = *(addText+i);
  464.                      /* Copy number to numstr */
  465.                      }
  466.                   numstr[len] = '\0';
  467.                   /* Add end-of-string */
  468.                   /* EasyCODE - */
  469.                   num = atoi(numstr);
  470.                   /* Convert string to integer */
  471.                   if (num > 1
  472.                       /* Number extracted is greater than 1 */)
  473.                      {
  474.                      // addText will be added later, only number contained
  475.                      // in addText is decremented;
  476.                      /* EasyCODE - */
  477.                      num--;
  478.                      itoa(num,numstr,10);
  479.                      /* Number is decremented and converted to a string */
  480.                      for (i=1;i<=len;i++)
  481.                         {
  482.                         *(addText+i) = numstr[i-1];
  483.                         }
  484.                      }
  485.                   else
  486.                      {
  487.                      // Extracted number is 1, addText is written
  488.                      /* EasyCODE - */
  489.                      strcpy(addText2,(addText+len+2));
  490.                      /* addText without <numstr> is copied to addText2 */
  491.                      /* EasyCODE - */
  492.                      len = strlen(contents);
  493.                      *(contents+len-1) = '\0';
  494.                      /* newline in contents is overwritten */
  495.                      /* EasyCODE - */
  496.                      /* Buffer assembled again */
  497.                      strcpy(inbuf,keyword);
  498.                      strcat(inbuf,delimiter);
  499.                      strcat(inbuf,contents);
  500.                      strcat(inbuf,addText2);
  501.                      strcat(inbuf,"\n\0");
  502.                      /* EasyCODE - */
  503.                      strcpy(addText,"");
  504.                      /* Clear addText */
  505.                      }
  506.                   }
  507.                StoreLine(inbuf,stream);
  508.                /* Write content of buffer to output file */
  509.                }
  510.             else
  511.                {
  512.                // There is only created text
  513.                if (*addText != '\0'
  514.                    /* addText is not empty */)
  515.                   {
  516.                   // If not SPACES for indent after
  517.                   // USING/VARYING/SEARCH 
  518.                   // addText is written;
  519.                   if ((strcmp(addText,SPACES1) != 0)&&
  520.                       (strcmp(addText,SPACES2) != 0)&&
  521.                       (strcmp(addText,SPACES3) != 0)
  522.                       /* addText is not equal SPACES1-3 */)
  523.                      {
  524.                      if (*addText == '<'
  525.                          /* First character in addText is '<' */)
  526.                         {
  527.                         // addText is written if number at begin of string
  528.                         // between < and > is 1.
  529.                         /* EasyCODE - */
  530.                         strcpy(addText2,addText);
  531.                         /* EasyCODE - */
  532.                         len = 0;
  533.                         /* EasyCODE - */
  534.                         addText2++;
  535.                         while (*addText2++ != '>')
  536.                            {
  537.                            len++;
  538.                            }
  539.                         for (i=1;i<=len;i++)
  540.                            {
  541.                            numstr[i-1] = *(addText+i);
  542.                            }
  543.                         numstr[len] = '\0';
  544.                         /* EasyCODE - */
  545.                         num = atoi(numstr);
  546.                         if (num > 1
  547.                             /* Extracted number is greaterer than 1 */)
  548.                            {
  549.                            // addText will be written later, only number contained
  550.                            // in addText is decremented;
  551.                            /* EasyCODE - */
  552.                            num--;
  553.                            itoa(num,numstr,10);
  554.                            for (i=1;i<=len;i++)
  555.                               {
  556.                               *(addText+i) = numstr[i-1];
  557.                               }
  558.                            }
  559.                         else
  560.                            {
  561.                            // addText is written
  562.                            /* EasyCODE - */
  563.                            strcpy(addText2,(addText+len+2));
  564.                            /* addText without <numstr> is copied to addText2 */
  565.                            /* EasyCODE - */
  566.                            /* Buffer assembled again */
  567.                            strcpy(inbuf,keyword);
  568.                            strcat(inbuf,delimiter);
  569.                            strcat(inbuf,addText2);
  570.                            strcat(inbuf,"\n\0");
  571.                            /* EasyCODE - */
  572.                            strcpy(addText,"");
  573.                            /* Clear addText */
  574.                            /* EasyCODE - */
  575.                            StoreLine(inbuf,stream);
  576.                            /* Write buffer to output file */
  577.                            }
  578.                         }
  579.                      else
  580.                         {
  581.                         // addText is added at begin of line
  582.                         /* EasyCODE - */
  583.                         /* Buffer assembled again */
  584.                         strcpy(inbuf,keyword);
  585.                         strcat(inbuf,delimiter);
  586.                         strcat(inbuf,addText);
  587.                         strcat(inbuf,"\n\0");
  588.                         if (strcmp(addText,"USING ")==0
  589.                             /* addText contains USING */)
  590.                            {
  591.                            strcpy(addText,SPACES1);
  592.                            /* SPACES1 copied to addText */
  593.                            /* to get indent for following lines */
  594.                            }
  595.                         if (strcmp(addText,"SEARCH ")==0
  596.                             /* addText contains SEARCH */)
  597.                            {
  598.                            strcpy(addText,SPACES2);
  599.                            /* SPACES2 copied to addText */
  600.                            /* to get indent for following lines */
  601.                            }
  602.                         if (strcmp(addText,"VARYING ")==0
  603.                             /* addText contains VARYING */)
  604.                            {
  605.                            strcpy(addText,SPACES3);
  606.                            /* SPACES3 copied to addText */
  607.                            /* to get indent for following lines */
  608.                            }
  609.                         if (!((strcmp(addText,SPACES1)==0)||
  610.                               (strcmp(addText,SPACES2)==0)||
  611.                               (strcmp(addText,SPACES3)==0))
  612.                             
  613.                             /* addText contains neither SPACES1 nor SPACES2 nor SPACES3 */)
  614.                            {
  615.                            strcpy(addText,"");
  616.                            /* Clear addText */
  617.                            }
  618.                         StoreLine(inbuf,stream);
  619.                         /* Buffer (=line) is written to the output file */
  620.                         }
  621.                      }
  622.                   }
  623.                else
  624.                   {
  625.                   // Comment is written unmodified
  626.                   /* EasyCODE - */
  627.                   StoreLine(inbuf,stream);
  628.                   }
  629.                }
  630.             }
  631.          }
  632.       else
  633.          {
  634.          // comment == FALSE
  635.          // Not only comment is written
  636.          if (*addText != '\0')
  637.             {
  638.             // There is additional text, the line
  639.             // has to be assembled again.
  640.             if (*addText != '<')
  641.                {
  642.                // Additional text is inserted at begin of line
  643.                if (*contents == '\0')
  644.                   {
  645.                   *contents = '\n';
  646.                   *(contents+1) = '\0';
  647.                   }
  648.                strcpy(inbuf,keyword);
  649.                strcat(inbuf,delimiter);
  650.                strcat(inbuf,addText);
  651.                strcat(inbuf,contents);
  652.                /* EasyCODE - */
  653.                // addText is cleared or modified
  654.                if (strcmp(addText,"USING ")==0
  655.                    /* addText contains USING */)
  656.                   {
  657.                   strcpy(addText,SPACES1);
  658.                   /* SPACES1 copied to addText */
  659.                   /* to get indent for following lines */
  660.                   }
  661.                if (strcmp(addText,"SEARCH ")==0
  662.                    /* addText contains SEARCH */)
  663.                   {
  664.                   strcpy(addText,SPACES2);
  665.                   /* SPACES2 copied to addText */
  666.                   /* to get indent for following lines */
  667.                   }
  668.                if (strcmp(addText,"VARYING ")==0
  669.                    /* addText contains VARYING */)
  670.                   {
  671.                   strcpy(addText,SPACES3);
  672.                   /* SPACES3 copied to addText */
  673.                   /* to get indent for following lines */
  674.                   }
  675.                if (!((strcmp(addText,SPACES1)==0)||
  676.                      (strcmp(addText,SPACES2)==0)||
  677.                      (strcmp(addText,SPACES3)==0))
  678.                    
  679.                    /* addText contains neither SPACES1 nor SPACES2 nor SPACES3 */)
  680.                   {
  681.                   strcpy(addText,"");
  682.                   /* Clear addText */
  683.                   }
  684.                }
  685.             else
  686.                {
  687.                // addText to be written at the end of the last 
  688.                // text line of the construct header
  689.                /* EasyCODE - */
  690.                // addText is written if number at begin of string
  691.                // between < and > is 1.
  692.                /* EasyCODE - */
  693.                strcpy(addText2,addText);
  694.                /* EasyCODE - */
  695.                len = 0;
  696.                /* EasyCODE - */
  697.                addText2++;
  698.                while (*addText2++ != '>')
  699.                   {
  700.                   len++;
  701.                   }
  702.                for (i=1;i<=len;i++)
  703.                   {
  704.                   numstr[i-1] = *(addText+i);
  705.                   }
  706.                numstr[len] = '\0';
  707.                /* EasyCODE - */
  708.                num = atoi(numstr);
  709.                if (num > 1)
  710.                   {
  711.                   // addText is added later, only number contained
  712.                   // in addText is decremented;
  713.                   /* EasyCODE - */
  714.                   num--;
  715.                   itoa(num,numstr,10);
  716.                   for (i=1;i<=len;i++)
  717.                      {
  718.                      *(addText+i) = numstr[i-1];
  719.                      }
  720.                   }
  721.                else
  722.                   {
  723.                   // addText2 contains addText without <numstr>
  724.                   /* EasyCODE - */
  725.                   strcpy(addText2,(addText+len+2));
  726.                   /* EasyCODE - */
  727.                   // newline '\n' in contents is overwritten
  728.                   /* EasyCODE - */
  729.                   len = strlen(contents);
  730.                   *(contents+len-1) = '\0';
  731.                   /* EasyCODE - */
  732.                   strcpy(inbuf,keyword);
  733.                   strcat(inbuf,delimiter);
  734.                   strcat(inbuf,contents);
  735.                   strcat(inbuf,addText2);
  736.                   strcat(inbuf,"\n\0");
  737.                   /* EasyCODE - */
  738.                   // Clear addText
  739.                   /* EasyCODE - */
  740.                   strcpy(addText,"");
  741.                   }
  742.                }
  743.             StoreLine(inbuf,stream);
  744.             }
  745.          else
  746.             {
  747.             // Line is written unmodified
  748.             /* EasyCODE - */
  749.             StoreLine(inbuf,stream);
  750.             }
  751.          }
  752.       }
  753.    }
  754. /* EasyCODE ) */
  755.  
  756. /* EasyCODE ( 16
  757.    StoreUnchanged */
  758.  
  759. /* EasyCODE F */
  760. void StoreUnchanged(FILE* stream, BOOL omit,
  761.                     char* keyword, char* ignore)
  762.                     
  763. // Writes an unmodified line to the output file,
  764. // if no keyword to be ignored is contained.
  765.    {
  766.    if (!omit
  767.        /* Omit indicator is FALSE */)
  768.       {
  769.       if (strcmp(keyword,ignore) != 0
  770.           /* Keyword does not match content of ignore */)
  771.          {
  772.          StoreLine(inbuf,stream);
  773.          /* Line is written */
  774.          }
  775.       else
  776.          {
  777.          strcpy(ignore,"");
  778.          /* Clear ignore */
  779.          }
  780.       }
  781.    }
  782. /* EasyCODE ) */
  783.  
  784. /* EasyCODE ( 17
  785.    StoreChanged */
  786.  
  787. /* EasyCODE F */
  788. void StoreChanged(FILE* stream, BOOL omit,
  789.                   char* keyword, char* delimiter)
  790.                   
  791. // Writes a new line ( = new keyword)
  792. // to the output file.
  793.    {
  794.    if (!omit
  795.        /* Omit indicator is FALSE */)
  796.       {
  797.       strcpy(inbuf,keyword);
  798.       *(delimiter+1)='\n';
  799.       *(delimiter+2)='\0';
  800.       strcat(inbuf,delimiter);
  801.       /* Copy keyword to buffer and add         */
  802.       /* delimiter, newline, and end-of-string; */
  803.       /* EasyCODE - */
  804.       StoreLine(inbuf,stream);
  805.       /* Write buffer to output file */
  806.       }
  807.    }
  808. /* EasyCODE ) */
  809.  
  810. /* EasyCODE ( 19
  811.    Set_ignore */
  812.  
  813. /* EasyCODE F */
  814. void Set_ignore(BOOL omit, char* ignore, char* keyword)
  815.  
  816. // Sets variable ignore
  817.    {
  818.    if (!omit
  819.        /* Omit indicator is FALSE */)
  820.       {
  821.       strcpy(ignore,keyword);
  822.       /* Copy keyword to ignore */
  823.       }
  824.    }
  825. /* EasyCODE ) */
  826.  
  827. /* EasyCODE ( 26
  828.    Set_depth */
  829.  
  830. /* EasyCODE F */
  831. void Set_depth(BOOL omit, int* depth, int value)
  832.  
  833. /* Sets variable depth */
  834.    {
  835.    if (!omit
  836.        /* Omit indicator is FALSE */)
  837.       {
  838.       if (value < MAX_DEPTH
  839.           /* Given value is less than maximum depth */)
  840.          {
  841.          *depth = value;
  842.          /* Depth gets value of "value" */
  843.          }
  844.       else
  845.          {
  846.          /* Print error message */
  847.          err_msg(0,ERR_TEXT4);
  848.          exit(1);
  849.          }
  850.       }
  851.    }
  852. /* EasyCODE ) */
  853.  
  854. /* EasyCODE ( 300
  855.    LookAhead */
  856.  
  857. /* EasyCODE F */
  858. int LookAhead(FILE* stream, BOOL omit,
  859.              char* delimiter,char* contents, 
  860.              int lineNum)
  861.              
  862. // Reads next line from input file, but resets file pointer
  863. // to the old position;
  864. // Delivers ID of keyword of line read ahead;
  865.    {
  866.    long posBefore;   /* Position of file pointer before read */
  867.    BOOL bEOF;        /* End-of-File flag */
  868.    int ID;           /* ID of next keyword */
  869.    if (!omit
  870.        /* Omit indicator is FALSE */)
  871.       {
  872.       posBefore = TellPos(stream);
  873.       bEOF = ReadLine(inbuf,stream);
  874.       /* Get file pointer position and read next line */
  875.       if (bEOF
  876.           /* End-of-File */)
  877.          {
  878.          /* Print error message */
  879.          err_msg(lineNum+1,ERR_TEXT2);
  880.          exit(1);
  881.          }
  882.       else
  883.          {
  884.          /* Reset file pointer and return keyword */
  885.          ID = GetKeyword(delimiter,contents);
  886.          SeekPos(posBefore,stream);
  887.          return (ID);
  888.          }
  889.       }
  890.    else
  891.       {
  892. /* EasyCODE < */
  893.       return (NO_KEYWORD);
  894. /* EasyCODE > */
  895.       }
  896.    }
  897. /* EasyCODE ) */
  898.  
  899. /* EasyCODE ( 378
  900.    main */
  901.  
  902. /* EasyCODE F */
  903. void main(int argc, char *argv[])
  904.  
  905. // Reads lines from the input file and writes them to the 
  906. // output file. Empty lines are skipped. From each line
  907. // the keyword is extracted using GetKeyword() and the ID
  908. // is returned. Dependent on the construct (unmodified or
  909. // to be converted) for each line (keyword) different functions
  910. // are called.
  911.    {
  912.  
  913.    /* EasyCODE ( 390
  914.       Info */
  915.    // If we have a contruct where the order of subtrees has to be changed
  916.    // the construct has to be processed twice.
  917.    // During the first processing (loop=1) the first subtree is skipped
  918.    // and further subtrees are written. Before the second processing
  919.    // (loop=2) the read pointer is reset to the saved start position(posA)
  920.    // of the first subtree in order to write this subtree. The read pointer
  921.    // is set to the saved end position(posB) afterwards.
  922.    // Depth contains the depth of nestings and is incremented at the start
  923.    // of SEARCH, PERFORMTESTAFTER, PERFORMAFTERVARYING, EXCEPTION
  924.    // and decremented at the corresponding end of the construct. 
  925.    // Depth is an index for posA, posB, loop, and the omit indicator.
  926.    // Depth is also incremented at the keyword COBPROGRAMM in order to
  927.    // control the suppression of Divisions using the omit indicator.
  928.    // Furthermore depth is incremented at each LEVEL and decremented 
  929.    // at each ENDLEVEL in order to control the limit of levels using the
  930.    // omit indicator again;
  931.    //
  932.    // To write text lines that are not comment lines if the comment option
  933.    // is enabled, "comment" is set to FALSE for that purpose.
  934.    // Sometimes it is necessary to know whether the following subtree
  935.    // contains only DUMMY constructs. This is done by a read ahead 
  936.    // provided in the function LookAhead.
  937.    /* EasyCODE ) */
  938.  
  939.    /* EasyCODE ( 391
  940.       Variables */
  941.    int    ID;                    /* ID of actual keyword */
  942.    int    i;                     /* General purpose */
  943.    int    ip = -1;               /* Position of input file in argument string */
  944.    int    op = -1;               /* Position of output file in argument string */
  945.    int    lineNum  = 0;          /* Actual line number */
  946.    int    lineMem;               /* Variable for saving the line number */
  947.    int    lines    = 1;          /* Number of lines in construct header of */
  948.                                  /* PERFORMTIMES, is passed to addText */ 
  949.    int    levelNum = 0;          /* Actual level */
  950.    int    maxlevel = MAX_DEPTH;  /* Maximum level */
  951.    int    depth    = 0;          /* Actual depth */
  952.    long   position;              /* Position of read pointer */
  953.    
  954.    char*  contents;              /* Content of line without keyword+delimiter */
  955.    char*  delimiter;             /* Delimiter of keyword */
  956.    char*  addText;               /* Additional Text for next text line */
  957.    char*  ignore;                /* Keyword to be ignored at next occurence */
  958.    char*  numstr;                /* Number string containing lines */
  959.    
  960.    FILE*  fdr;                   /* Input file */
  961.    FILE*  fdw;                   /* Output file */
  962.    
  963.    long   posA[MAX_DEPTH];       /* Array of start positions */
  964.    long   posB[MAX_DEPTH];       /* Array of end positions   */
  965.    int    loop[MAX_DEPTH];       /* Array of loop indicators */
  966.    BOOL   omit[MAX_DEPTH];       /* Array of omit indicators */
  967.    BOOL   bEOF = FALSE;          /* EOF indicator */
  968.    BOOL   comment = FALSE;       /* Comment option flag */
  969.    BOOL   commem  = FALSE;       /* General purpose */
  970.    BOOL   divisions[4];          /* Array of division suppresions */
  971.    /* EasyCODE ) */
  972.  
  973.    /* EasyCODE ( 392
  974.       Initializations */
  975.    /* Allocate memory for pointers */
  976.    contents    = malloc(I_BUFSIZE*sizeof(char));
  977.    delimiter   = malloc((MAX_DELIMITERLEN+1)*sizeof(char));
  978.    addText     = malloc((MAX_ADDTEXTLEN+1)*sizeof(char));
  979.    ignore      = malloc((MAX_KEYWORDLEN+1)*sizeof(char));
  980.    numstr      = malloc(4*sizeof(char));
  981.    
  982.    /* Initialize pointers */
  983.    *contents   = '\0';
  984.    *delimiter  = '\0';
  985.    *addText    = '\0';
  986.    *ignore     = '\0';
  987.    
  988.    /* Initialize arrays */ 
  989.    posA[0]       = 0;
  990.    posB[0]       = 0;
  991.    loop[0]       = 0;
  992.    omit[0]       = FALSE;
  993.    for (i=0;i<4;i++)
  994.       {
  995.       divisions[i] = TRUE;  /* Initialize divisions array */
  996.       }
  997.    for (i=1;i<MAX_DEPTH;i++)
  998.       {
  999.       loop[i] = 1;    /* Initialize loop array */
  1000.       }
  1001.    /* EasyCODE ) */
  1002.    /* Check command line parameters */
  1003.    check_parms(argc,argv,&ip,&op,&maxlevel,&comment,divisions);
  1004.    if (maxlevel == 0)
  1005.       {
  1006.       maxlevel = MAX_DEPTH;
  1007.       }
  1008.    /* Open files */
  1009.    fdr = OpenInput(argv[ip]);
  1010.    fdw = OpenOutput(argv[op]);
  1011.    /* EasyCODE - */
  1012.    /* Save read position */
  1013.    position = TellPos(fdr);
  1014.    /* Read first line */
  1015.    bEOF = ReadLine(inbuf,fdr);
  1016.    /* Increment line number */
  1017.    lineNum++;
  1018.    while (!bEOF
  1019.           /* While not EOF reached */)
  1020.       {
  1021.       /* Get keyword */
  1022.       ID = GetKeyword(delimiter, contents);
  1023.       switch (ID
  1024.               /* ID of keyword */)
  1025.          {
  1026.          case ETF_EASYCODE:
  1027.             // Only change component indicator,
  1028.             // the rest is saved unmodified.
  1029.  
  1030.             /* EasyCODE ( 401
  1031.                Change component indicator to SPX */
  1032.  
  1033.             /* EasyCODE :
  1034.                Change component indicator to SPX */
  1035.                {
  1036.                char buffer[sizeof(inbuf)+3];
  1037.                char *p = NULL;
  1038.                /* EasyCODE - */
  1039.                // Copy original text to result buffer.
  1040.                strcpy (buffer, inbuf);
  1041.                if (// Search for delimiter after 
  1042.                    // keyword in buffer.
  1043.                    p = strpbrk (buffer, "=:;"))
  1044.                   {
  1045.                   // If found, go behind delimiter,
  1046.                   // copy "SPX", and search for delimter
  1047.                   // in original text (must exist).
  1048.                   p++;
  1049.                   strcpy (p, "SPX");
  1050.                   p = strpbrk (inbuf, "=:;");
  1051.                   if (// In original text search first
  1052.                       // blank after delimiter
  1053.                       // (behind component indicator).
  1054.                       p = strchr (p, ' '))
  1055.                      {
  1056.                      // Add rest of original text
  1057.                      // to result buffer.
  1058.                      strcat (buffer, p);
  1059.                      }
  1060.                   }
  1061.                // Copy buffer back.
  1062.                strcpy (inbuf, buffer);
  1063.                }
  1064.             /* EasyCODE ) */
  1065.             StoreUnchanged(fdw, omit[depth], TABLE[ID], ignore);
  1066.             break;
  1067.          case ETF_SHORTINFO:
  1068.          case ETF_ENDSHORTINFO:
  1069.          case ETF_OPTIONS:
  1070.          case ETF_IFLAYOUT:
  1071.          case ETF_LEVELNUMBERS:
  1072.          case ETF_LINENUMBERS:
  1073.          case ETF_CONSTRUCTNUMBERS:
  1074.          case ETF_SCREENFONT:
  1075.          case ETF_PRINTERFONT:
  1076.          case ETF_LASTLEVELID:
  1077.          case ETF_ENDOPTIONS:
  1078.          case ETF_IF:
  1079.          case ETF_THEN:
  1080.          case ETF_ELSE:
  1081.          case ETF_ENDIF:
  1082.             StoreUnchanged(fdw, omit[depth], TABLE[ID], ignore);
  1083.             break;
  1084.          case ETF_DUMMY:
  1085.             StoreUnchanged(fdw, omit[depth], TABLE[ID], ignore);
  1086.             break;
  1087.          case ETF_PERFORMTESTBEFORE:
  1088.             StoreChanged(fdw, omit[depth], TABLE[ETF_WHILE], delimiter);
  1089.             /* EasyCODE - */
  1090.             StoreChanged(fdw, omit[depth], TABLE[ETF_NOT], delimiter);
  1091.             break;
  1092.          case ETF_PERFORMTESTBEFOREBODY:
  1093.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDNOT], delimiter);
  1094.             /* EasyCODE - */
  1095.             StoreChanged(fdw, omit[depth], TABLE[ETF_WHILEBODY], delimiter);
  1096.             break;
  1097.          case ETF_ENDPERFORMTESTBEFORE:
  1098.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDWHILE], delimiter);
  1099.             break;
  1100.          case ETF_ONCONDITIONBRANCH:
  1101.          case ETF_ONCONDITIONBRANCHBODY:
  1102.          case ETF_ENDONCONDITIONBRANCH:
  1103.          case ETF_ONSELECTORBRANCH:
  1104.          case ETF_ONSELECTORBRANCHBODY:
  1105.          case ETF_ENDONSELECTORBRANCH:
  1106.          case ETF_TEXT:
  1107.          case ETF_ENDTEXT:
  1108.             StoreUnchanged(fdw, omit[depth], TABLE[ID], ignore);
  1109.             break;
  1110.          case ETF_LEVEL:
  1111.             // Depth is incremented and therefore a new level created.
  1112.             // This also occurs if new level has not been processed 
  1113.             // (until yet) because it is locked from above.
  1114.             // The omit indicator of the new level is initialzed with
  1115.             // TRUE. Therefore it is only necessary to check the
  1116.             // omit indicator from the higher level instead of checking
  1117.             // all omit indicators from all higher levels. (If a level 
  1118.             // is locked all sublevels are locked, too.
  1119.             /* EasyCODE - */
  1120.             Set_depth(FALSE,&depth,depth+1);
  1121.             omit[depth]=TRUE;
  1122.             /* EasyCODE - */
  1123.             levelNum++;
  1124.             /* EasyCODE - */
  1125.             // Depth was incremented (in either case), therefore the
  1126.             // omit indicator of the higher level has to be checked.
  1127.             if (!omit[depth-1])
  1128.                {
  1129.                omit[depth]=FALSE;
  1130.                /* EasyCODE - */
  1131.                // comment set to FALSE for writing the level header.
  1132.                /* EasyCODE - */
  1133.                commem = comment;
  1134.                comment = FALSE;
  1135.                if (levelNum > maxlevel)
  1136.                   {
  1137.                   // Ignore keyword
  1138.                   /* EasyCODE - */
  1139.                   // Just content of level header is written
  1140.                   /* EasyCODE - */
  1141.                   ID = LookAhead(fdr,FALSE,delimiter,contents,lineNum);
  1142.                   if (ID == ETF_DUMMY)
  1143.                      {
  1144.                      StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  1145.                      /* EasyCODE - */
  1146.                      StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  1147.                      /* EasyCODE - */
  1148.                      Set_ignore(FALSE, ignore, TABLE[ETF_DUMMY]);
  1149.                      }
  1150.                   }
  1151.                else
  1152.                   {
  1153.                   // Whole level is written
  1154.                   /* EasyCODE - */
  1155.                   StoreUnchanged(fdw, FALSE, TABLE[ID], ignore);
  1156.                   }
  1157.                }
  1158.             break;
  1159.          case ETF_LEVELBODY:
  1160.             if (!omit[depth-1])
  1161.                {
  1162.                comment = commem;
  1163.                if (levelNum > maxlevel)
  1164.                   {
  1165.                   // Ignore keyword
  1166.                   /* EasyCODE - */
  1167.                   // Whole level body is ignored - omit indicator set to TRUE
  1168.                   /* EasyCODE - */
  1169.                   omit[depth]=TRUE;
  1170.                   }
  1171.                else
  1172.                   {
  1173.                   StoreUnchanged(fdw, FALSE, TABLE[ID], ignore);
  1174.                   }
  1175.                }
  1176.             break;
  1177.          case ETF_ENDLEVEL:
  1178.             if (!omit[depth-1])
  1179.                {
  1180.                if (levelNum > maxlevel)
  1181.                   {
  1182.                   // Ignore keyword
  1183.                   }
  1184.                else
  1185.                   {
  1186.                   StoreUnchanged(fdw, FALSE, TABLE[ID], ignore);
  1187.                   }
  1188.                }
  1189.             // For depth and level have been incremented in either case,
  1190.             // whether level construct is precessed including its content 
  1191.             // or not, both have to be decremented in either case now.
  1192.             /* EasyCODE - */
  1193.             Set_depth(FALSE,&depth,depth-1);
  1194.             /* EasyCODE - */
  1195.             levelNum--;
  1196.             break;
  1197.          case ETF_LINE:
  1198.             StoreText(fdw, omit[depth], comment, TABLE[ID], delimiter, addText, contents);
  1199.             break;
  1200.          case ETF_OFFSET:
  1201.             // Ignore keyword "Offset"
  1202.             break;
  1203.          case ETF_PERFORMBEFOREVARYING:
  1204.             StoreChanged(fdw, omit[depth], TABLE[ETF_FRAME], delimiter);
  1205.             /* EasyCODE - */
  1206.             ID = LookAhead(fdr,omit[depth],delimiter,contents,lineNum);
  1207.             if (ID == ETF_DUMMY)
  1208.                {
  1209.                StoreChanged(fdw, omit[depth], TABLE[ETF_TEXT], delimiter);
  1210.                /* EasyCODE - */
  1211.                Set_addText( omit[depth], addText, "PERFORM WITH TEST BEFORE ");
  1212.                /* EasyCODE - */
  1213.                StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1214.                /* EasyCODE - */
  1215.                Set_addText(omit[depth], addText, "VARYING ");
  1216.                /* EasyCODE - */
  1217.                StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1218.                /* EasyCODE - */
  1219.                StoreChanged(fdw, omit[depth], TABLE[ETF_ENDTEXT], delimiter);
  1220.                /* EasyCODE - */
  1221.                Set_ignore(omit[depth], ignore, TABLE[ETF_DUMMY]);
  1222.                }
  1223.             else
  1224.                {
  1225.                StoreChanged(fdw, omit[depth], TABLE[ETF_TEXT], delimiter);
  1226.                /* EasyCODE - */
  1227.                Set_addText( omit[depth], addText, "PERFORM WITH TEST BEFORE ");
  1228.                /* EasyCODE - */
  1229.                StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1230.                /* EasyCODE - */
  1231.                Set_addText(omit[depth], addText, "VARYING ");
  1232.                /* EasyCODE - */
  1233.                Set_ignore(omit[depth], ignore, TABLE[ETF_TEXT]);
  1234.                }
  1235.             break;
  1236.          case ETF_PERFORMBEFOREVARYINGBODY:
  1237.             StoreChanged(fdw, omit[depth], TABLE[ETF_FRAMEBODY], delimiter);
  1238.             /* EasyCODE - */
  1239.             Set_addText( omit[depth], addText, "");
  1240.             break;
  1241.          case ETF_ENDPERFORMBEFOREVARYING:
  1242.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDFRAMEBODY], delimiter);
  1243.             /* EasyCODE - */
  1244.             StoreChanged(fdw, omit[depth], TABLE[ETF_TEXT], delimiter);
  1245.             /* EasyCODE - */
  1246.             Set_addText( omit[depth], addText, " ");
  1247.             /* EasyCODE - */
  1248.             StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1249.             /* EasyCODE - */
  1250.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDTEXT], delimiter);
  1251.             /* EasyCODE - */
  1252.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDFRAME], delimiter);
  1253.             break;
  1254.          case ETF_PERFORMTESTAFTER:
  1255.             // Increment depth, initilize omit indicator
  1256.             // with TRUE (see ETF_LEVEL).
  1257.             /* EasyCODE - */
  1258.             Set_depth(FALSE,&depth,depth+1);
  1259.             omit[depth]=TRUE;
  1260.             /* EasyCODE - */
  1261.             // Depth was incremented (in either case), therefore the
  1262.             // omit indicator of the higher level has to be checked.
  1263.             if (!omit[depth-1])
  1264.                {
  1265.                if (loop[depth] == 1)
  1266.                   {
  1267.                   posA[depth] = position;
  1268.                   }
  1269.                else
  1270.                   {
  1271.                   omit[depth]=FALSE;
  1272.                   StoreChanged(fdw, FALSE, TABLE[ETF_UNTIL], delimiter);
  1273.                   }
  1274.                }
  1275.             break;
  1276.          case ETF_UNTIL:
  1277.             if (!omit[depth-1])
  1278.                {
  1279.                if (loop[depth] == 1)
  1280.                   {
  1281.                   omit[depth] = FALSE;
  1282.                   /* EasyCODE - */
  1283.                   StoreChanged(fdw, FALSE, TABLE[ETF_REPEAT], delimiter);
  1284.                   }
  1285.                else
  1286.                   {
  1287.                   SeekPos(posB[depth],fdr);
  1288.                   }
  1289.                }
  1290.             break;
  1291.          case ETF_ENDPERFORMTESTAFTER:
  1292.             if (!omit[depth-1])
  1293.                {
  1294.                if (loop[depth] == 1)
  1295.                   {
  1296.                   posB[depth] = position;
  1297.                   loop[depth] = 2;
  1298.                   SeekPos(posA[depth], fdr);
  1299.                   lineMem = lineNum;
  1300.                   /* EasyCODE - */
  1301.                   Set_depth(FALSE,&depth,depth-1);
  1302.                   }
  1303.                else
  1304.                   {
  1305.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDREPEAT], delimiter);
  1306.                   /* EasyCODE - */
  1307.                   lineNum = lineMem;
  1308.                   *(loop+depth)=1;
  1309.                   Set_depth(FALSE,&depth,depth-1);
  1310.                   }
  1311.                }
  1312.             else
  1313.                {
  1314.                // Depth has also to be decremented
  1315.                // if whole construct was skipped.
  1316.                /* EasyCODE - */
  1317.                Set_depth(FALSE,&depth,depth-1);
  1318.                }
  1319.             break;
  1320.          case ETF_PERFORMOUTLINE:
  1321.             StoreChanged(fdw, omit[depth], TABLE[ETF_CALL], delimiter);
  1322.             /* EasyCODE - */
  1323.             // comment set to FALSE to always write name
  1324.             /* EasyCODE - */
  1325.             commem = comment;
  1326.             comment = FALSE;
  1327.             break;
  1328.          case ETF_ENDPERFORMOUTLINE:
  1329.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDCALL], delimiter);
  1330.             /* EasyCODE - */
  1331.             comment = commem;
  1332.             break;
  1333.          case ETF_EXIT:
  1334.             StoreChanged(fdw, omit[depth], TABLE[ETF_TEXT], delimiter);
  1335.             /* EasyCODE - */
  1336.             Set_addText( omit[depth], addText, "EXIT");
  1337.             /* EasyCODE - */
  1338.             StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1339.             /* EasyCODE - */
  1340.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDTEXT], delimiter);
  1341.             break;
  1342.          case ETF_GOBACK:
  1343.             StoreChanged(fdw, omit[depth], TABLE[ETF_TEXT], delimiter);
  1344.             /* EasyCODE - */
  1345.             Set_addText( omit[depth], addText, "GOBACK");
  1346.             /* EasyCODE - */
  1347.             StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1348.             /* EasyCODE - */
  1349.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDTEXT], delimiter);
  1350.             break;
  1351.          case ETF_COBPROGRAM:
  1352.             // Depth is incremented, omit indicator is
  1353.             // initialized with TRUE (see ETF_LEVEL).
  1354.             /* EasyCODE - */
  1355.             Set_depth(FALSE,&depth,depth+1);
  1356.             omit[depth]=TRUE;
  1357.             break;
  1358.          case ETF_IDDIV:
  1359.             // Depth was incremented (in either case), therefore the
  1360.             // omit indicator of the higher level has to be checked.
  1361.             if (!omit[depth-1])
  1362.                {
  1363.                if (divisions[0])
  1364.                   {
  1365.                   // Identification Division shall be written
  1366.                   /* EasyCODE - */
  1367.                   omit[depth] = FALSE;
  1368.                   /* EasyCODE - */
  1369.                   StoreChanged(fdw, FALSE, TABLE[ETF_BLOCK], delimiter);
  1370.                   /* EasyCODE - */
  1371.                   StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  1372.                   /* EasyCODE - */
  1373.                   Set_addText( FALSE, addText, "IDENTIFICATION DIVISION");
  1374.                   /* EasyCODE - */
  1375.                   StoreText(fdw, FALSE, comment, TABLE[ETF_LINE], "=", addText, contents);
  1376.                   /* EasyCODE - */
  1377.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  1378.                   /* EasyCODE - */
  1379.                   StoreChanged(fdw, FALSE, TABLE[ETF_BLOCKBODY], delimiter);
  1380.                   }
  1381.                else
  1382.                   {
  1383.                   // Identification Division shall be suppressed
  1384.                   /* EasyCODE - */
  1385.                   omit[depth] = TRUE;
  1386.                   }
  1387.                }
  1388.             break;
  1389.          case ETF_ENVIRONMENTDIV:
  1390.             // Depth was incremented (in either case), therefore the
  1391.             // omit indicator of the higher level has to be checked.
  1392.             if (!omit[depth-1])
  1393.                {
  1394.                StoreChanged(fdw, omit[depth], TABLE[ETF_ENDBLOCK], delimiter);
  1395.                if (divisions[1])
  1396.                   {
  1397.                   // Environment Division shall be written
  1398.                   /* EasyCODE - */
  1399.                   omit[depth] = FALSE;
  1400.                   /* EasyCODE - */
  1401.                   StoreChanged(fdw, FALSE, TABLE[ETF_BLOCK], delimiter);
  1402.                   /* EasyCODE - */
  1403.                   StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  1404.                   /* EasyCODE - */
  1405.                   Set_addText( FALSE, addText, "ENVIRONMENT DIVISION");
  1406.                   /* EasyCODE - */
  1407.                   StoreText(fdw, FALSE, comment, TABLE[ETF_LINE], "=", addText, contents);
  1408.                   /* EasyCODE - */
  1409.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  1410.                   /* EasyCODE - */
  1411.                   StoreChanged(fdw, FALSE, TABLE[ETF_BLOCKBODY], delimiter);
  1412.                   }
  1413.                else
  1414.                   {
  1415.                   // Environment Division shall be suppressed
  1416.                   /* EasyCODE - */
  1417.                   omit[depth] = TRUE;
  1418.                   }
  1419.                }
  1420.             break;
  1421.          case ETF_DATADIV:
  1422.             // Depth was incremented (in either case), therefore the
  1423.             // omit indicator of the higher level has to be checked.
  1424.             if (!omit[depth-1])
  1425.                {
  1426.                StoreChanged(fdw, omit[depth], TABLE[ETF_ENDBLOCK], delimiter);
  1427.                if (divisions[2])
  1428.                   {
  1429.                   // Data Division shall be written
  1430.                   /* EasyCODE - */
  1431.                   omit[depth] = FALSE;
  1432.                   /* EasyCODE - */
  1433.                   StoreChanged(fdw, FALSE, TABLE[ETF_BLOCK], delimiter);
  1434.                   /* EasyCODE - */
  1435.                   StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  1436.                   /* EasyCODE - */
  1437.                   Set_addText( FALSE, addText, "DATA DIVISION");
  1438.                   /* EasyCODE - */
  1439.                   StoreText(fdw, FALSE, comment, TABLE[ETF_LINE], "=", addText, contents);
  1440.                   /* EasyCODE - */
  1441.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  1442.                   /* EasyCODE - */
  1443.                   StoreChanged(fdw, FALSE, TABLE[ETF_BLOCKBODY], delimiter);
  1444.                   }
  1445.                else
  1446.                   {
  1447.                   // Data Division shall be suppressed
  1448.                   /* EasyCODE - */
  1449.                   omit[depth] = TRUE;
  1450.                   }
  1451.                }
  1452.             break;
  1453.          case ETF_PROCDIVPARAM:
  1454.             // comment set to FALSE to always write parameters
  1455.             /* EasyCODE - */
  1456.             commem = comment;
  1457.             comment = FALSE;
  1458.             /* EasyCODE - */
  1459.             // Depth was incremented (in either case), therefore the
  1460.             // omit indicator of the higher level has to be checked.
  1461.             if (!omit[depth-1])
  1462.                {
  1463.                StoreChanged(fdw, omit[depth], TABLE[ETF_ENDBLOCK], delimiter);
  1464.                if (divisions[3])
  1465.                   {
  1466.                   // Procedure Division shall be written
  1467.                   /* EasyCODE - */
  1468.                   omit[depth] = FALSE;
  1469.                   /* EasyCODE - */
  1470.                   StoreChanged(fdw, FALSE, TABLE[ETF_BLOCK], delimiter);
  1471.                   /* EasyCODE - */
  1472.                   StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  1473.                   /* EasyCODE - */
  1474.                   Set_addText( FALSE, addText, "PROCEDURE DIVISION");
  1475.                   /* EasyCODE - */
  1476.                   StoreText(fdw, FALSE, comment, TABLE[ETF_LINE], "=", addText, contents);
  1477.                   /* EasyCODE - */
  1478.                   // Look ahaed
  1479.                   /* EasyCODE - */
  1480.                   ID = LookAhead(fdr,FALSE,delimiter,contents,lineNum);
  1481.                   if (ID == ETF_DUMMY)
  1482.                      {
  1483.                      Set_addText( FALSE, addText, "USING <parameter>");
  1484.                      /* EasyCODE - */
  1485.                      StoreText(fdw, FALSE, comment, TABLE[ETF_LINE], "=", addText, contents);
  1486.                      /* EasyCODE - */
  1487.                      StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  1488.                      /* EasyCODE - */
  1489.                      Set_ignore(FALSE, ignore, TABLE[ETF_DUMMY]);
  1490.                      }
  1491.                   else
  1492.                      {
  1493.                      Set_ignore(FALSE, ignore, TABLE[ETF_TEXT]);
  1494.                      /* EasyCODE - */
  1495.                      Set_addText( FALSE, addText, "USING ");
  1496.                      }
  1497.                   }
  1498.                else
  1499.                   {
  1500.                   // Procedure Division shall be suppressed
  1501.                   /* EasyCODE - */
  1502.                   omit[depth] = TRUE;
  1503.                   }
  1504.                }
  1505.             break;
  1506.          case ETF_PROCDIVBODY:
  1507.             comment = commem;
  1508.             /* EasyCODE - */
  1509.             StoreChanged(fdw, omit[depth], TABLE[ETF_BLOCKBODY], delimiter);
  1510.             /* EasyCODE - */
  1511.             Set_addText( omit[depth], addText, "");
  1512.             break;
  1513.          case ETF_ENDCOBPROGRAM:
  1514.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDBLOCK], delimiter);
  1515.             /* EasyCODE - */
  1516.             // Depth has to be decremented always
  1517.             /* EasyCODE - */
  1518.             Set_depth(FALSE,&depth,depth-1);
  1519.             break;
  1520.          case ETF_SECTION:
  1521.             // comment set to FALSE to always write name
  1522.             /* EasyCODE - */
  1523.             commem = comment;
  1524.             comment = FALSE;
  1525.             /* EasyCODE - */
  1526.             StoreChanged(fdw, omit[depth], TABLE[ETF_PROCEDURE], delimiter);
  1527.             break;
  1528.          case ETF_SECTIONBODY:
  1529.             comment = commem;
  1530.             /* EasyCODE - */
  1531.             StoreChanged(fdw, omit[depth], TABLE[ETF_PROCEDUREBODY], delimiter);
  1532.             break;
  1533.          case ETF_ENDSECTION:
  1534.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDPROCEDURE], delimiter);
  1535.             break;
  1536.          case ETF_PARAGRAPH:
  1537.             // comment set to FALSE to always write name
  1538.             /* EasyCODE - */
  1539.             commem = comment;
  1540.             comment = FALSE;
  1541.             /* EasyCODE - */
  1542.             StoreChanged(fdw, omit[depth], TABLE[ETF_PROCEDURE], delimiter);
  1543.             break;
  1544.          case ETF_PARAGRAPHBODY:
  1545.             comment = commem;
  1546.             /* EasyCODE - */
  1547.             StoreChanged(fdw, omit[depth], TABLE[ETF_PROCEDUREBODY], delimiter);
  1548.             break;
  1549.          case ETF_ENDPARAGRAPH:
  1550.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDPROCEDURE], delimiter);
  1551.             break;
  1552.          case ETF_PERFORMINLINE:
  1553.             StoreChanged(fdw, omit[depth], TABLE[ETF_BLOCK], delimiter);
  1554.             /* EasyCODE - */
  1555.             StoreChanged(fdw, omit[depth], TABLE[ETF_TEXT], delimiter);
  1556.             /* EasyCODE - */
  1557.             Set_addText( omit[depth], addText, "PERFORM ");
  1558.             /* EasyCODE - */
  1559.             StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1560.             /* EasyCODE - */
  1561.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDTEXT], delimiter);
  1562.             /* EasyCODE - */
  1563.             StoreChanged(fdw, omit[depth], TABLE[ETF_BLOCKBODY], delimiter);
  1564.             break;
  1565.          case ETF_ENDPERFORMINLINE:
  1566.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDBLOCK], delimiter);
  1567.             break;
  1568.          case ETF_PERFORMTIMES:
  1569.             // Header of construct is processed twice.
  1570.             // First time for getting number of text lines.
  1571.             // Second time to write text lines an append
  1572.             // TIMES to last line
  1573.             /* EasyCODE - */
  1574.             // Increment depth, initialize omit indicator
  1575.             // with TRUE
  1576.             /* EasyCODE - */
  1577.             Set_depth(FALSE,&depth,depth+1);
  1578.             omit[depth]=TRUE;
  1579.             /* EasyCODE - */
  1580.             // Depth was incremented (in either case), therefore the
  1581.             // omit indicator of the higher level has to be checked.
  1582.             if (!omit[depth-1])
  1583.                {
  1584.                if (loop[depth] == 1)
  1585.                   {
  1586.                   posA[depth] = position;
  1587.                   /* EasyCODE - */
  1588.                   lineMem = lineNum;
  1589.                   }
  1590.                else
  1591.                   {
  1592.                   omit[depth]=FALSE;
  1593.                   /* EasyCODE - */
  1594.                   StoreChanged(fdw, FALSE, TABLE[ETF_FOR], delimiter);
  1595.                   /* EasyCODE - */
  1596.                   itoa(lines,numstr,10);
  1597.                   /* EasyCODE - */
  1598.                   // Number of text line where TIMES has to
  1599.                   // be appended is passed;
  1600.                   /* EasyCODE - */
  1601.                   strcpy(addText,"<");
  1602.                   strcat(addText,numstr);
  1603.                   strcat(addText,">");
  1604.                   strcat(addText," TIMES");
  1605.                   }
  1606.                }
  1607.             break;
  1608.          case ETF_PERFORMTIMESBODY:
  1609.             if (!omit[depth-1])
  1610.                {
  1611.                if (loop[depth] == 1)
  1612.                   {
  1613.                   loop[depth] = 2;
  1614.                   SeekPos(posA[depth], fdr);
  1615.                   lines = lineNum - lineMem - 1 - 3;
  1616.                   lineMem = lineNum;
  1617.                   /* EasyCODE - */
  1618.                   Set_depth(FALSE,&depth,depth-1);
  1619.                   }
  1620.                else
  1621.                   {
  1622.                   StoreChanged(fdw, FALSE, TABLE[ETF_FORBODY], delimiter);
  1623.                   /* EasyCODE - */
  1624.                   Set_addText(FALSE, addText, "");
  1625.                   /* EasyCODE - */
  1626.                   lineNum = lineMem;
  1627.                   loop[depth]=1;
  1628.                   Set_depth(FALSE,&depth,depth-1);
  1629.                   }
  1630.                }
  1631.             else
  1632.                {
  1633.                // Depth has also to be incremented if
  1634.                // whole construct header was skipped
  1635.                /* EasyCODE - */
  1636.                Set_depth(FALSE,&depth,depth-1);
  1637.                }
  1638.             break;
  1639.          case ETF_ENDPERFORMTIMES:
  1640.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDFOR], delimiter);
  1641.             break;
  1642.          case ETF_PERFORMAFTERVARYING:
  1643.             // Increment depth, initialize omit 
  1644.             // indicator with TRUE
  1645.             /* EasyCODE - */
  1646.             Set_depth(FALSE,&depth,depth+1);
  1647.             omit[depth]=TRUE;
  1648.             /* EasyCODE - */
  1649.             // Depth was incremented (in either case), therefore the
  1650.             // omit indicator of the higher level has to be checked.
  1651.             if (!omit[depth-1])
  1652.                {
  1653.                if (loop[depth] == 1)
  1654.                   {
  1655.                   posA[depth] = position;
  1656.                   }
  1657.                else
  1658.                   {
  1659.                   omit[depth]=FALSE;
  1660.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDFRAMEBODY], delimiter);
  1661.                   /* EasyCODE - */
  1662.                   ID = LookAhead(fdr,FALSE,delimiter,contents,lineNum);
  1663.                   if (ID == ETF_DUMMY)
  1664.                      {
  1665.                      StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  1666.                      /* EasyCODE - */
  1667.                      Set_addText(FALSE, addText, "VARYING ");
  1668.                      /* EasyCODE - */
  1669.                      StoreText(fdw, FALSE, comment, TABLE[ETF_LINE], "=", addText, contents);
  1670.                      /* EasyCODE - */
  1671.                      StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  1672.                      /* EasyCODE - */
  1673.                      Set_ignore(FALSE, ignore, TABLE[ETF_DUMMY]);
  1674.                      }
  1675.                   else
  1676.                      {
  1677.                      Set_addText(FALSE, addText, "VARYING ");
  1678.                      }
  1679.                   }
  1680.                }
  1681.             break;
  1682.          case ETF_VARYING:
  1683.             if (!omit[depth-1])
  1684.                {
  1685.                if (loop[depth] == 1)
  1686.                   {
  1687.                   omit[depth] = FALSE;
  1688.                   /* EasyCODE - */
  1689.                   StoreChanged(fdw, FALSE, TABLE[ETF_FRAME], delimiter);
  1690.                   /* EasyCODE - */
  1691.                   StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  1692.                   /* EasyCODE - */
  1693.                   Set_addText(FALSE, addText, "PERFORM WITH TEST AFTER ");
  1694.                   /* EasyCODE - */
  1695.                   StoreText(fdw, FALSE, comment, TABLE[ETF_LINE], "=", addText, contents);
  1696.                   /* EasyCODE - */
  1697.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  1698.                   /* EasyCODE - */
  1699.                   StoreChanged(fdw, FALSE, TABLE[ETF_FRAMEBODY], delimiter);
  1700.                   }
  1701.                else
  1702.                   {
  1703.                   Set_addText( FALSE, addText, "");
  1704.                   /* EasyCODE - */
  1705.                   SeekPos(posB[depth],fdr);
  1706.                   }
  1707.                }
  1708.             break;
  1709.          case ETF_ENDPERFORMAFTERVARYING:
  1710.             if (!omit[depth-1])
  1711.                {
  1712.                if (loop[depth] == 1)
  1713.                   {
  1714.                   posB[depth] = position;
  1715.                   loop[depth] = 2;
  1716.                   SeekPos(posA[depth], fdr);
  1717.                   lineMem = lineNum;
  1718.                   /* EasyCODE - */
  1719.                   Set_depth(FALSE,&depth,depth-1);
  1720.                   }
  1721.                else
  1722.                   {
  1723.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDFRAME], delimiter);
  1724.                   /* EasyCODE - */
  1725.                   lineNum = lineMem;
  1726.                   loop[depth]=1;
  1727.                   Set_depth(FALSE,&depth,depth-1);
  1728.                   }
  1729.                }
  1730.             else
  1731.                {
  1732.                // Depth has to be decremented even
  1733.                // if whole construct was skipped.
  1734.                /* EasyCODE - */
  1735.                Set_depth(FALSE,&depth,depth-1);
  1736.                }
  1737.             break;
  1738.          case ETF_EXITPERFORM:
  1739.             StoreChanged(fdw, omit[depth], TABLE[ETF_TEXT], delimiter);
  1740.             /* EasyCODE - */
  1741.             Set_addText( omit[depth], addText, "EXIT PERFORM");
  1742.             /* EasyCODE - */
  1743.             StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1744.             /* EasyCODE - */
  1745.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDTEXT], delimiter);
  1746.             break;
  1747.          case ETF_EXITTOTEST:
  1748.             StoreChanged(fdw, omit[depth], TABLE[ETF_TEXT], delimiter);
  1749.             /* EasyCODE - */
  1750.             Set_addText( omit[depth], addText, "EXIT TO TEST");
  1751.             /* EasyCODE - */
  1752.             StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1753.             /* EasyCODE - */
  1754.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDTEXT], delimiter);
  1755.             break;
  1756.          case ETF_EXITPROGRAM:
  1757.             StoreChanged(fdw, omit[depth], TABLE[ETF_TEXT], delimiter);
  1758.             /* EasyCODE - */
  1759.             Set_addText( omit[depth], addText, "EXIT PROGRAM");
  1760.             /* EasyCODE - */
  1761.             StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1762.             /* EasyCODE - */
  1763.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDTEXT], delimiter);
  1764.             break;
  1765.          case ETF_EXTERNALCALL:
  1766.             StoreChanged(fdw, omit[depth], TABLE[ETF_CALL], delimiter);
  1767.             /* EasyCODE - */
  1768.             // comment set to FALSE to 
  1769.             // always write name+parameters
  1770.             /* EasyCODE - */
  1771.             commem = comment;
  1772.             comment = FALSE;
  1773.             /* EasyCODE - */
  1774.             // Look ahead
  1775.             /* EasyCODE - */
  1776.             ID = LookAhead(fdr,omit[depth],delimiter,contents,lineNum);
  1777.             if (ID == ETF_DUMMY)
  1778.                {
  1779.                StoreChanged(fdw, omit[depth], TABLE[ETF_TEXT], delimiter);
  1780.                /* EasyCODE - */
  1781.                Set_addText( omit[depth], addText, "CALL  <name>");
  1782.                /* EasyCODE - */
  1783.                StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1784.                /* EasyCODE - */
  1785.                Set_ignore(omit[depth], ignore, TABLE[ETF_DUMMY]);
  1786.                }
  1787.             else
  1788.                {
  1789.                Set_addText( omit[depth], addText, "CALL  ");
  1790.                /* EasyCODE - */
  1791.                Set_ignore(omit[depth], ignore, TABLE[ETF_ENDTEXT]);
  1792.                }
  1793.             break;
  1794.          case ETF_EXTERNALCALLPARAM:
  1795.             // Look ahead
  1796.             /* EasyCODE - */
  1797.             ID = LookAhead(fdr,omit[depth],delimiter,contents,lineNum);
  1798.             if (ID == ETF_DUMMY)
  1799.                {
  1800.                Set_addText( omit[depth], addText, "USING <parameter>");
  1801.                /* EasyCODE - */
  1802.                StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1803.                /* EasyCODE - */
  1804.                StoreChanged(fdw, omit[depth], TABLE[ETF_ENDTEXT], delimiter);
  1805.                /* EasyCODE - */
  1806.                Set_ignore(omit[depth], ignore, TABLE[ETF_DUMMY]);
  1807.                }
  1808.             else
  1809.                {
  1810.                Set_ignore(omit[depth], ignore, TABLE[ETF_TEXT]);
  1811.                /* EasyCODE - */
  1812.                Set_addText( omit[depth], addText, "USING ");
  1813.                }
  1814.             break;
  1815.          case ETF_ENDEXTERNALCALL:
  1816.             comment = commem;
  1817.             /* EasyCODE - */
  1818.             Set_addText( omit[depth], addText, "");
  1819.             /* EasyCODE - */
  1820.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDCALL], delimiter);
  1821.             break;
  1822.          case ETF_SEARCH:
  1823.             // Depth will always be incremented, even if
  1824.             // SEARCH construct is skipped, in order to 
  1825.             // keep consistence.
  1826.             // Omit indicator of corresponding depth is
  1827.             // initialized with TRUE.
  1828.             /* EasyCODE - */
  1829.             Set_depth(FALSE,&depth,depth+1);
  1830.             omit[depth]=TRUE;
  1831.             /* EasyCODE - */
  1832.             // Depth was incremented (in either case), therefore the
  1833.             // omit indicator of the higher level has to be checked.
  1834.             if (!omit[depth-1])
  1835.                {
  1836.                omit[depth] = FALSE;
  1837.                StoreChanged(fdw, FALSE, TABLE[ETF_FRAME], delimiter);
  1838.                /* EasyCODE - */
  1839.                ID = LookAhead(fdr,FALSE,delimiter,contents,lineNum);
  1840.                if (ID == ETF_DUMMY)
  1841.                   {
  1842.                   StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  1843.                   /* EasyCODE - */
  1844.                   Set_addText( FALSE, addText, "SEARCH <table>");
  1845.                   /* EasyCODE - */
  1846.                   StoreText(fdw, FALSE, comment, TABLE[ETF_LINE], "=", addText, contents);
  1847.                   /* EasyCODE - */
  1848.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  1849.                   /* EasyCODE - */
  1850.                   Set_ignore(FALSE, ignore, TABLE[ETF_DUMMY]);
  1851.                   }
  1852.                else
  1853.                   {
  1854.                   Set_addText(FALSE, addText, "SEARCH ");
  1855.                   }
  1856.                loop[depth] = 1;
  1857.                }
  1858.             break;
  1859.          case ETF_ATEND:
  1860.             if (!omit[depth-1])
  1861.                {
  1862.                if (loop[depth] == 1)
  1863.                   {
  1864.                   Set_addText( FALSE, addText, "");
  1865.                   /* EasyCODE - */
  1866.                   omit[depth] = TRUE;
  1867.                   posA[depth] = position;
  1868.                   }
  1869.                else
  1870.                   {
  1871.                   StoreChanged(fdw, FALSE, TABLE[ETF_ONCONDITIONREST], delimiter);
  1872.                   /* EasyCODE - */
  1873.                   StoreChanged(fdw, FALSE, TABLE[ETF_ONCONDITIONBRANCH], delimiter);
  1874.                   /* EasyCODE - */
  1875.                   StoreChanged(fdw, FALSE, TABLE[ETF_DUMMY], delimiter);
  1876.                   /* EasyCODE - */
  1877.                   StoreChanged(fdw, FALSE, TABLE[ETF_ONCONDITIONBRANCHBODY], delimiter);
  1878.                   /* EasyCODE - */
  1879.                   StoreChanged(fdw, FALSE, TABLE[ETF_FRAME], delimiter);
  1880.                   /* EasyCODE - */
  1881.                   StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  1882.                   /* EasyCODE - */
  1883.                   Set_addText(FALSE, addText, "AT END ");
  1884.                   /* EasyCODE - */
  1885.                   StoreText(fdw, FALSE, comment, TABLE[ETF_LINE], "=", addText, contents);
  1886.                   /* EasyCODE - */
  1887.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  1888.                   /* EasyCODE - */
  1889.                   StoreChanged(fdw, FALSE, TABLE[ETF_FRAMEBODY], delimiter);
  1890.                   }
  1891.                }
  1892.             break;
  1893.          case ETF_SEARCHBODY:
  1894.             if (!omit[depth-1])
  1895.                {
  1896.                if (loop[depth] == 1)
  1897.                   {
  1898.                   omit[depth] = FALSE;
  1899.                   /* EasyCODE - */
  1900.                   StoreChanged(fdw, FALSE, TABLE[ETF_FRAMEBODY], delimiter);
  1901.                   /* EasyCODE - */
  1902.                   StoreChanged(fdw, FALSE, TABLE[ETF_ONCONDITION], delimiter);
  1903.                   }
  1904.                else
  1905.                   {
  1906.                   SeekPos(posB[depth],fdr);
  1907.                   }
  1908.                }
  1909.             break;
  1910.          case ETF_ENDSEARCH:
  1911.             if (!omit[depth-1])
  1912.                {
  1913.                if (loop[depth] == 1)
  1914.                   {
  1915.                   posB[depth] = position;
  1916.                   loop[depth] = 2;
  1917.                   SeekPos(posA[depth], fdr);
  1918.                   lineMem = lineNum;
  1919.                   }
  1920.                else
  1921.                   {
  1922.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDFRAMEBODY], delimiter);
  1923.                   /* EasyCODE - */
  1924.                   StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  1925.                   /* EasyCODE - */
  1926.                   Set_addText(FALSE, addText, " ");
  1927.                   /* EasyCODE - */
  1928.                   StoreText(fdw, FALSE, comment, TABLE[ETF_LINE], "=", addText, contents);
  1929.                   /* EasyCODE - */
  1930.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  1931.                   /* EasyCODE - */
  1932.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDFRAME], delimiter);
  1933.                   /* EasyCODE - */
  1934.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDONCONDITIONBRANCH], delimiter);
  1935.                   /* EasyCODE - */
  1936.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDONCONDITION], delimiter);
  1937.                   /* EasyCODE - */
  1938.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDFRAMEBODY], delimiter);
  1939.                   /* EasyCODE - */
  1940.                   StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  1941.                   /* EasyCODE - */
  1942.                   Set_addText(FALSE, addText, " ");
  1943.                   /* EasyCODE - */
  1944.                   StoreText(fdw, FALSE, comment, TABLE[ETF_LINE], "=", addText, contents);
  1945.                   /* EasyCODE - */
  1946.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  1947.                   /* EasyCODE - */
  1948.                   StoreChanged(fdw, FALSE, TABLE[ETF_ENDFRAME], delimiter);
  1949.                   /* EasyCODE - */
  1950.                   lineNum = lineMem;
  1951.                   /* EasyCODE - */
  1952.                   loop[depth]=1;
  1953.                   /* EasyCODE - */
  1954.                   Set_depth(FALSE,&depth,depth-1);
  1955.                   }
  1956.                }
  1957.             else
  1958.                {
  1959.                // Depth is always decremented
  1960.                // even if whole construct was skipped
  1961.                /* EasyCODE - */
  1962.                Set_depth(FALSE,&depth,depth-1);
  1963.                }
  1964.             break;
  1965.          case ETF_ENTRY:
  1966.             // comment set to FALSE to always
  1967.             // write name+parameters
  1968.             /* EasyCODE - */
  1969.             commem = comment;
  1970.             comment = FALSE;
  1971.             /* EasyCODE - */
  1972.             // Look ahaed
  1973.             /* EasyCODE - */
  1974.             ID = LookAhead(fdr,omit[depth],delimiter,contents,lineNum);
  1975.             if (ID == ETF_DUMMY)
  1976.                {
  1977.                StoreChanged(fdw, omit[depth], TABLE[ETF_TEXT], delimiter);
  1978.                /* EasyCODE - */
  1979.                Set_addText( omit[depth], addText, "ENTRY <name>");
  1980.                /* EasyCODE - */
  1981.                StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  1982.                /* EasyCODE - */
  1983.                Set_ignore(omit[depth], ignore, TABLE[ETF_DUMMY]);
  1984.                }
  1985.             else
  1986.                {
  1987.                Set_addText( omit[depth], addText, "ENTRY ");
  1988.                /* EasyCODE - */
  1989.                Set_ignore(omit[depth], ignore, TABLE[ETF_ENDTEXT]);
  1990.                }
  1991.             break;
  1992.          case ETF_ENTRYUSING:
  1993.             // Look ahead
  1994.             /* EasyCODE - */
  1995.             ID = LookAhead(fdr,omit[depth],delimiter,contents,lineNum);
  1996.             if (ID == ETF_DUMMY)
  1997.                {
  1998.                Set_addText( omit[depth], addText, "USING <parameter>");
  1999.                /* EasyCODE - */
  2000.                StoreText(fdw, omit[depth], comment, TABLE[ETF_LINE], "=", addText, contents);
  2001.                /* EasyCODE - */
  2002.                StoreChanged(fdw, omit[depth], TABLE[ETF_ENDTEXT], delimiter);
  2003.                /* EasyCODE - */
  2004.                Set_ignore(omit[depth], ignore, TABLE[ETF_DUMMY]);
  2005.                }
  2006.             else
  2007.                {
  2008.                Set_ignore(omit[depth], ignore, TABLE[ETF_TEXT]);
  2009.                /* EasyCODE - */
  2010.                Set_addText( omit[depth], addText, "USING ");
  2011.                }
  2012.             break;
  2013.          case ETF_ENDENTRY:
  2014.             comment = commem;
  2015.             /* EasyCODE - */
  2016.             Set_addText( omit[depth], addText, "");
  2017.             break;
  2018.          case ETF_EXCEPTION:
  2019.             // Increment depth, initialize omit indicator
  2020.             // with TRUE
  2021.             /* EasyCODE - */
  2022.             Set_depth(FALSE,&depth,depth+1);
  2023.             omit[depth]=TRUE;
  2024.             /* EasyCODE - */
  2025.             // Depth was incremented (in either case), therefore the
  2026.             // omit indicator of the higher level has to be checked.
  2027.             if (!omit[depth-1])
  2028.                {
  2029.                if (loop[depth] == 1)
  2030.                   {
  2031.                   posA[depth] = position;
  2032.                   }
  2033.                else
  2034.                   {
  2035.                   omit[depth]=FALSE;
  2036.                   StoreChanged(fdw, FALSE, TABLE[ETF_IF], delimiter);
  2037.                   /* EasyCODE - */
  2038.                   // comment set to FALSE to always
  2039.                   // write exception
  2040.                   /* EasyCODE - */
  2041.                   commem = comment;
  2042.                   comment = FALSE;
  2043.                   }
  2044.                }
  2045.             break;
  2046.          case ETF_ONEXCEPTION:
  2047.             if (!omit[depth-1])
  2048.                {
  2049.                omit[depth] = FALSE;
  2050.                if (loop[depth] == 1)
  2051.                   {
  2052.                   // Look ahead
  2053.                   /* EasyCODE - */
  2054.                   ID = LookAhead(fdr,FALSE,delimiter,contents,lineNum);
  2055.                   if (ID == ETF_DUMMY)
  2056.                      {
  2057.                      StoreChanged(fdw, FALSE, TABLE[ETF_TEXT], delimiter);
  2058.                      /* EasyCODE - */
  2059.                      StoreChanged(fdw, FALSE, TABLE[ETF_ENDTEXT], delimiter);
  2060.                      /* EasyCODE - */
  2061.                      Set_ignore(FALSE, ignore, TABLE[ETF_DUMMY]);
  2062.                      }
  2063.                   }
  2064.                else
  2065.                   {
  2066.                   comment = commem;
  2067.                   /* EasyCODE - */
  2068.                   SeekPos(posB[depth],fdr);
  2069.                   }
  2070.                }
  2071.             break;
  2072.          case ETF_EXCEPTIONBODY:
  2073.             if (!omit[depth-1])
  2074.                {
  2075.                if (loop[depth] == 1)
  2076.                   {
  2077.                   posB[depth] = position;
  2078.                   loop[depth] = 2;
  2079.                   SeekPos(posA[depth], fdr);
  2080.                   lineMem = lineNum;
  2081.                   /* EasyCODE - */
  2082.                   Set_depth(FALSE,&depth,depth-1);
  2083.                   }
  2084.                else
  2085.                   {
  2086.                   StoreChanged(fdw, FALSE, TABLE[ETF_THEN], delimiter);
  2087.                   /* EasyCODE - */
  2088.                   lineNum = lineMem;
  2089.                   loop[depth]=1;
  2090.                   Set_depth(FALSE,&depth,depth-1);
  2091.                   }
  2092.                }
  2093.             else
  2094.                {
  2095.                // Depth has also to be decremented
  2096.                // even if whole construct was skipped
  2097.                /* EasyCODE - */
  2098.                Set_depth(FALSE,&depth,depth-1);
  2099.                }
  2100.             break;
  2101.          case ETF_NOTEXCEPTIONBODY:
  2102.             StoreChanged(fdw, omit[depth], TABLE[ETF_ELSE], delimiter);
  2103.             break;
  2104.          case ETF_ENDEXCEPTION:
  2105.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDIF], delimiter);
  2106.             break;
  2107.          case ETF_EVALUATE:
  2108.             StoreChanged(fdw, omit[depth], TABLE[ETF_ONSELECTOR], delimiter);
  2109.             break;
  2110.          case ETF_EVALUATEBODY:
  2111.             StoreChanged(fdw, omit[depth], TABLE[ETF_ONSELECTORLIST], delimiter);
  2112.             break;
  2113.          case ETF_EVALUATEOTHER:
  2114.             StoreChanged(fdw, omit[depth], TABLE[ETF_ONSELECTORREST], delimiter);
  2115.             /* EasyCODE - */
  2116.             StoreChanged(fdw, omit[depth], TABLE[ETF_ONSELECTORBRANCH], delimiter);
  2117.             /* EasyCODE - */
  2118.             StoreChanged(fdw, omit[depth], TABLE[ETF_DUMMY], delimiter);
  2119.             /* EasyCODE - */
  2120.             StoreChanged(fdw, omit[depth], TABLE[ETF_ONSELECTORBRANCHBODY], delimiter);
  2121.             break;
  2122.          case ETF_ENDEVALUATE:
  2123.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDONSELECTORBRANCH], delimiter);
  2124.             /* EasyCODE - */
  2125.             StoreChanged(fdw, omit[depth], TABLE[ETF_ENDONSELECTOR], delimiter);
  2126.             break;
  2127.          case NO_KEYWORD:
  2128.             /* Skip empty lines */
  2129.             break;
  2130.          case ERROR_KEYWORD:
  2131.             err_msg(lineNum,ERR_TEXT1);
  2132.             /* EasyCODE - */
  2133.             exit(1);
  2134.          case EOF_KEYWORD:
  2135.             err_msg(lineNum,ERR_TEXT2);
  2136.             /* EasyCODE - */
  2137.             exit(1);
  2138.          default:
  2139.             err_msg(lineNum,ERR_TEXT3);
  2140.             /* EasyCODE - */
  2141.             exit(1);
  2142.          }
  2143.       /* Save read position */
  2144.       position = TellPos(fdr);
  2145.       /* Read next line */
  2146.       bEOF = ReadLine(inbuf,fdr);
  2147.       /* Increment line number */
  2148.       lineNum++;
  2149.       }
  2150.    /* Close files */
  2151.    CloseFile(fdr);
  2152.    CloseFile(fdw);
  2153.    }
  2154. /* EasyCODE ) */
  2155. /* EasyCODE ) */
  2156.